package stark.app.function.beat;

import android.graphics.Color;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.stark.beat.lib.core.BeatSoundType;

import stark.app.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;

/**
 * Author：daizhongbin on 2023/6/12
 * Email：1027154338@qq.com
 * Desc:
 */
public class BeatSoundAdapter extends StkProviderMultiAdapter<BeatSoundType> {

    private BeatSoundType selectBeatSoundType;

    public BeatSoundAdapter() {
        super(3);
        addItemProvider(new ItemProvider());
    }

    public void setSelectBeatSoundType(BeatSoundType selectBeatSoundType) {
        this.selectBeatSoundType = selectBeatSoundType;
        notifyDataSetChanged();
    }

    private class ItemProvider extends BaseItemProvider<BeatSoundType> {

        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_beat_sounds;
        }

        @Override
        public void convert(@NonNull BaseViewHolder holder, BeatSoundType beatSoundType) {
            holder.setText(R.id.tvName, beatSoundType.getName());
            if (beatSoundType == selectBeatSoundType) {
                holder.setTextColor(R.id.tvName, Color.parseColor("#FF0000"));
            } else {
                holder.setTextColor(R.id.tvName, Color.parseColor("#000000"));
            }
        }
    }

}
